package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import com.jt.vo.PageResult;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 刘昱江
 * 时间 2021/5/11
 */

@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public SysResult  login(@RequestBody User user){
        String token =  userService.findUserUp(user);

        return  token ==null? SysResult.fail():SysResult.success(token);
    }

    @GetMapping("/list")
    public SysResult getUserList(PageResult pageResult){
       return SysResult.success(userService.getUserList(pageResult));

    }
    @PutMapping("/status/{id}/{status}")
    public  SysResult  changeStatus( User user){
            userService.changeStatus(user);
            return SysResult.success();
    }


}
